import os

from langchain.agents import AgentType
from langchain.agents import initialize_agent
from langchain.agents import load_tools
from langchain_openai import OpenAI

os.environ["SERPAPI_API_KEY"] = "eedd2489d2f50dc4f302d914908069b6e17500e42f809c8ea0b45f17186498e0"

"""
    ReAct示例：AgentExecutor
    pip install langchain
"""
llm = OpenAI(temperature=0.9,
             base_url="https://api.openai-hk.com/v1",
                     api_key='hk-0amgwp10000255022bdd816341db25b54dc2e46787aee69f')
tools = load_tools(["serpapi", "llm-math"], llm=llm)
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
agent.invoke("What was the high temperature in SF yesterday in Fahrenheit? What is that number raised to the .023 power?")